package com.ht.demo.service.convert.monitor;

import java.util.ArrayList;
import java.util.List;

import com.ht.demo.common.pojo.bo.monitor.LoginInfoBO;
import com.ht.demo.dao.domain.monitor.LoginInfoDO;
import org.apache.commons.collections.CollectionUtils;

/**
 * BO与DO实体类转换
 * 系统登录日志，登录记录对象 login_info
 * @author hdengxian
 *  @date 2023-07-31
 */
public class LoginInfoBeanUtil {

    public static LoginInfoDO convertToDO(LoginInfoBO srcObj) {
        LoginInfoDO targetObj = new LoginInfoDO();
        if (srcObj == null) {
            return targetObj;
        }

        targetObj.setId(srcObj.getLoginInfoId());//$column.columnComment
        targetObj.setLoginNo(srcObj.getLoginNo());//登录账号
        targetObj.setUserName(srcObj.getUserName());//用户姓名
        targetObj.setToken(srcObj.getToken());
        targetObj.setIpaddr(srcObj.getIpaddr());//登录地址
        targetObj.setLoginLocation(srcObj.getLoginLocation());//登录地点
        targetObj.setBrowser(srcObj.getBrowser());//浏览器
        targetObj.setOptionSys(srcObj.getOptionSys());//操作系统
        targetObj.setLoginStatus(srcObj.getLoginStatus());//登录状态
        targetObj.setMsg(srcObj.getMsg());//操作信息
        targetObj.setLoginTime(srcObj.getLoginTime());//登录日期
        targetObj.setCreateBy(srcObj.getCreateBy());//创建者
        targetObj.setCreateTime(srcObj.getCreateTime());//创建时间
        targetObj.setUpdateBy(srcObj.getUpdateBy());//更新者
        targetObj.setUpdateTime(srcObj.getUpdateTime());//更新时间
        return targetObj;
    }

    public static LoginInfoBO convertToBO(LoginInfoDO srcObj) {
        LoginInfoBO targetObj = new LoginInfoBO();
        if (srcObj == null) {
            return targetObj;
        }

        targetObj.setLoginInfoId(srcObj.getId());//$column.columnComment
        targetObj.setLoginNo(srcObj.getLoginNo());//登录账号
        targetObj.setUserName(srcObj.getUserName());//用户姓名
        targetObj.setToken(srcObj.getToken());
        targetObj.setIpaddr(srcObj.getIpaddr());//登录地址
        targetObj.setLoginLocation(srcObj.getLoginLocation());//登录地点
        targetObj.setBrowser(srcObj.getBrowser());//浏览器
        targetObj.setOptionSys(srcObj.getOptionSys());//操作系统
        targetObj.setLoginStatus(srcObj.getLoginStatus());//登录状态
        targetObj.setMsg(srcObj.getMsg());//操作信息
        targetObj.setLoginTime(srcObj.getLoginTime());//登录日期
        targetObj.setCreateBy(srcObj.getCreateBy());//创建者
        targetObj.setCreateTime(srcObj.getCreateTime());//创建时间
        targetObj.setUpdateBy(srcObj.getUpdateBy());//更新者
        targetObj.setUpdateTime(srcObj.getUpdateTime());//更新时间
        return targetObj;
    }

    public static List<LoginInfoBO> convertToBOList(List<LoginInfoDO> doList) {
        List<LoginInfoBO> boList = new ArrayList<>();
        if (CollectionUtils.isEmpty(doList)) return boList;

        doList.stream().forEach(d -> boList.add(LoginInfoBeanUtil.convertToBO(d)));
        return boList;
    }

    public static List<LoginInfoDO> convertToDOList(List<LoginInfoBO> boList) {
        List<LoginInfoDO> doList = new ArrayList<>();
        if (CollectionUtils.isEmpty(boList)) return doList;

        boList.stream().forEach(b -> doList.add(LoginInfoBeanUtil.convertToDO(b)));
        return doList;
    }

}